Building the Model: Advanced Elements > Subroutines > Subroutine Example

Subroutine Example

Suppose that you build a Copy Center model and it is necessary to define the processing time at the operator assisted machines as a function of two parameters: Order Quantity and Quality Level. In addition, you would also like to write the processing times at each copy machine to a file called Report.Dat.

 

Because the operation logic is identical at both machines, a subroutine may be used to execute the group of statements required. Notice in the Process Logic pictured next that Subroutine OrderTime is called, and each order's Quantity, Quality, and Ticket attributes are passed as arguments. The third argument is simply a constant value, 1 or 2, which represents the location from which the subroutine was called (i.e., 1 if called from OpAsist1 or 2 if called from OpAsist2). The operation logic, which calls the subroutine, and routing are shown below. The subroutine itself is shown later in this section.

Subroutines Edit Table

The Subroutine edit table lists the name of the subroutine, the return type, the parameters to be passed to the subroutine, and the logic. Notice that the subroutine ID corresponds to the subroutine name called in the processing logic above and that the subroutine has four parameters (P1, P2, P3 and P4) corresponding to the four arguments passed to the subroutine. Also note that the subroutine is of type real since the return value will be a real valued processing time.

Subroutine Parameters

The subroutine parameters, M (for mean) and SD (for standard deviation), are defined by clicking on the Parameters heading button. These values are unique to each inspection location, and are passed to the subroutine as parameters of the normally distributed inspection time.

Subroutine Logic

The final step in defining the subroutine is to specify the logic to be processed when the subroutine is called. In this example, the logic should include a processing time, a procedure to write the values of the attributes to a file, and a routing decision based on the values of the two attributes. The logic window is accessed by clicking on the Logic heading button.

The first line of the logic calculates the order time as a function of the Quantity and Quality attributes passed as parameters. These parameters are used as arguments in two user defined functions, ProcTime() and QualFactor(). Function ProcTime() returns a time value based on the number of copies in the order, while function QualFactor() returns a scale factor depending upon the quality level desired. Operation time is determined by simply multiplying the process time by the scale factor.

 

Once the order time has been determined, this value is written to the file Report.Dat. Included with the operation time is the job number and the location at which the job was processed.

 

The last line of the logic returns the order time value to the processing logic.


© 2012 ProModel Corporation • 556 East Technology Avenue • Orem, UT 84097 • Support: 888-776-6633 • www.promodel.com